package controller;

import java.util.Observable;
import java.util.Observer;

import javax.swing.JTextField;

import model.CModel;

//This is a ConcreteObserver that Implements the Observer interface
public class sumFelt extends JTextField implements Observer {

	public sumFelt(CModel model) {

		setEditable(false);
		
		setHorizontalAlignment(RIGHT);

		model.addObserver(this); // register with the ConcreteSubject, to be
									// able to receive updates
		update(model, null);

	}

	@Override
	public void update(Observable obs, Object args) {

		if (((CModel) obs).sum() != 0)
			setText("" + ((CModel) obs).sum());
		else
			setText("0.0000");

	}

}